package com.education.student.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.education.model.Print;
import com.education.model.ResultDo;
import com.education.service.IPrintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 学生打印准考证控制层
 *
 * @author 郭伟(新增)
 */
@Api(value = "/api/student", description = "打印准考证")
@RestController
@RequestMapping("/api/student")
public class PrintController {
    /**
     * 日志记录文件
     */
    private static Logger LOGGER = LogManager.getLogger(PrintController.class);

    /**
     * 注入业务层
     */
    @Reference
    private IPrintService printService;

    @ApiOperation(notes = "print", httpMethod = "GET", value = "获取准考证")
    @RequestMapping(path = "/print", method = RequestMethod.GET)
    public ResultDo<Object> searchPringInfo(HttpSession session) throws Exception {

//        Print list = printService.searchPrintInfo(4);
        Print list = printService.searchPrintInfo((Integer) session.getAttribute("stuId"));
        ResultDo<Object> resultDo = new ResultDo<Object>();
        if (list!=null) {
            resultDo.setResCode(0);
            resultDo.setResMsg("请求成功");
            resultDo.setResData(list);
        } else {
            resultDo.setResCode(-1);
            resultDo.setResMsg("请求失败");
        }
        return resultDo;
    }


}
